package com.guilin.system.service.impl;


import java.util.List;
import com.guilin.common.utils.DateUtils;
import com.guilin.system.service.SurveyQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.guilin.mapper.SurveyQuestionMapper;
import com.guilin.domain.SurveyQuestion;


/**
 * 题目Service业务层处理
 * 
 * @author xiaoqi
 * @date 2025-06-24
 */
@Service
public class SurveyQuestionServiceImpl implements SurveyQuestionService
{
    @Autowired
    private SurveyQuestionMapper surveyQuestionMapper;

    /**
     * 查询题目
     * 
     * @param id 题目主键
     * @return 题目
     */
    @Override
    public SurveyQuestion selectSurveyQuestionById(Long id)
    {
        return surveyQuestionMapper.selectSurveyQuestionById(id);
    }

    /**
     * 查询题目列表
     * 
     * @param surveyQuestion 题目
     * @return 题目
     */
    @Override
    public List<SurveyQuestion> selectSurveyQuestionList(SurveyQuestion surveyQuestion)
    {
        return surveyQuestionMapper.selectSurveyQuestionList(surveyQuestion);
    }

    /**
     * 新增题目
     * 
     * @param surveyQuestion 题目
     * @return 结果
     */
    @Override
    public int insertSurveyQuestion(SurveyQuestion surveyQuestion)
    {
        surveyQuestion.setCreateTime(DateUtils.getNowDate());
        return surveyQuestionMapper.insertSurveyQuestion(surveyQuestion);
    }

    /**
     * 修改题目
     * 
     * @param surveyQuestion 题目
     * @return 结果
     */
    @Override
    public int updateSurveyQuestion(SurveyQuestion surveyQuestion)
    {
        surveyQuestion.setUpdateTime(DateUtils.getNowDate());
        return surveyQuestionMapper.updateSurveyQuestion(surveyQuestion);
    }

    /**
     * 批量删除题目
     * 
     * @param ids 需要删除的题目主键
     * @return 结果
     */
    @Override
    public int deleteSurveyQuestionByIds(Long[] ids)
    {
        return surveyQuestionMapper.deleteSurveyQuestionByIds(ids);
    }

    /**
     * 删除题目信息
     * 
     * @param id 题目主键
     * @return 结果
     */
    @Override
    public int deleteSurveyQuestionById(Long id)
    {
        return surveyQuestionMapper.deleteSurveyQuestionById(id);
    }


    /**
     * 根据问卷ID查询题目ID列表
     * @param questionnaireId
     * @return
     */
    public List<Long> selectQuestionIdsByQuestionnaireId(Long questionnaireId) {
        return surveyQuestionMapper.selectQuestionIdsByQuestionnaireId(questionnaireId);
    }
}
